# -*- coding: utf-8 -*-
from common import orm
from common.utils.types import Enum

AWARD_POOL_RATIO = 0.03


WINNER_AWARD_TYPE = Enum({
    'DAILY': ('daily', 'daily'),
    'WEEKLY': ('weekly', 'weekly'),
    'TOTAL': ('total', 'total'),
})

AWARD_CONFIG = {
    WINNER_AWARD_TYPE.DAILY: {
        1:  0.15,
        2:  0.12,
        3:  0.096,
        4:  0.075,
        5:  0.054,
        6:  0.039,
        7:  0.027,
        8:  0.018,
        9:  0.012,
        10:  0.009,
        'default':  0.0044,
    },
    WINNER_AWARD_TYPE.WEEKLY: {
        1:  0.33,
        2:  0.18,
        3:  0.09,
        4:  0.076,
        5:  0.064,
        6:  0.06,
        7:  0.056,
        8:  0.052,
        9:  0.048,
        10:  0.044,
    },
    WINNER_AWARD_TYPE.TOTAL: {
        1:  0.36,
        2:  0.15,
        3:  0.09,
        4:  0.072,
        5:  0.068,
        6:  0.06,
        7:  0.056,
        8:  0.052,
        9:  0.048,
        10:  0.044,
    },
}


class WinnerAwardRecord(orm.Model):
    __tablename__ = "winner_award_record"
    id = orm.Column(orm.BigInteger, primary_key=True)
    user_id = orm.Column(orm.Integer)
    start = orm.Column(orm.DATETIME)
    end = orm.Column(orm.DATETIME)
    type = orm.Column(orm.VARCHAR)
    rank = orm.Column(orm.Integer)
    amount = orm.Column(orm.FLOAT, default=0)
    transaction_id = orm.Column(orm.BigInteger)
